var assert = require('chai').assert;

function add() {
  return Array.prototype.slice.call(arguments).reduce(function(prev, curr) {
    return prev + curr;
  }, 0);
}

describe('add()', function() {

    it('[1,2]', function () {
        assert.equal(add(1, 2), 3)
    })

    it('[1,2,3]', function () {
        assert.equal(add(1, 2, 3), 6)
    })

});

describe('add() matrix', function() {

    var tests = [
        {args: [1, 2], expected: 3},
        {args: [1, 2, 3], expected: 6},
        {args: [1, 2, 3, 4], expected: 10}
    ];

    tests.forEach(function(test) {
        it('correctly adds ' + test.args.length + ' args', function() {
            // var res = add.apply(null, test.args);
            assert.equal(add(...test.args), test.expected);
        });
    });

});
